
// 分页查询
function pageCart(pageNum, pageSize, phone) {
    var getData;
    $.ajax({
        url: '/cart/list',
        dataType: 'json',
        type: 'get',
        async: false,
        data: {
            phone: phone,
            pageNum: pageNum,
            pageSize: pageSize
        },
        success: function (res) {
            getData = res;
        }
    });
    return getData;
}

function deleteCart(e){
    var deleteData;
    if (e == undefined) {
        var arr = [];
        $(".checkBox").each(function () {
            var getTarget = $(this);
            if (getTarget.prop('checked')) {
                arr.push(getTarget.val());
            }
        });
        if (arr.length == 0) {
            alert("请选择要删除的数据");
            return;
        }
        deleteData = '[' + arr.toString() + ']';
    } else {
        deleteData = '[' + $(e).val() + ']';
    }
    $.ajax({
        url: '/cart/admin/delete',
        type: 'post',
        dataType: 'json',
        contentType: 'application/json;charset=utf-8',
        data: deleteData,
        success: function (res) {
            if (res.code != 200) {
                alert(res.message);
                return;
            }
            alert("删除成功");
            show();
        }

    })
}

function igGetCart(id){
    var getData;
    $.ajax({
        url: '/cart/admin/' + id,
        dataType: 'json',
        type: 'get',
        async: false,
        success: function (res) {
            getData = res;
        }
    })
    return getData;
}

